<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;

/**
 * 不需要验证客户端的
 */

//微信接入验
Route::rule('wechat_check', 'Index/check', 'GET|POST')->name('wechat-check');

/**
 * 不需要验证登录状态的
 */
////获取系统登录Token
//Route::post('get_sys_token', 'Common/getToken')->name('wechat-get_sys_token');
//获取接口状态(参数全部原样返回)
Route::rule('get_web_status', 'Api/websiteStatus', 'GET|POST')->name('wechat-get_web_status');
//微信静默登录回调地址
Route::rule('wechat_login', 'Login/oauthCallback', 'GET|POST')->name('wechat-oauth_callback');
//获取首页banner
Route::rule('banner', 'Index/getAppBanner', 'GET|POST')->name('app-get_banner');
//测试页面
Route::any('test', 'Index/test');
//支付通知（金燕e付）
Route::any('pay-notify', 'Pay/payNotify');
//手动刷新支付状态
Route::any('pay-refresh', 'Pay/getPayResult');
//测试退款
Route::any('pay-refund', 'Pay/refund');
//支付成功页面
Route::any('pay-success', 'Pay/pay_success');
/**
 * 需要验证登录状态的
 */
Route::group(function () {
    /* 页面开始 */
    //404页面
    Route::get('404', 'Index/notFound');
    //首页
    Route::get('index', 'Index/index');
    //分类
    Route::get('store', 'Store/index');
    //我的
    Route::get('user', 'User/index');
    //签到
    Route::get('sign', 'User/sign');
    //代金券首页
    Route::get('cashcard', 'Cashcard/index');
    //代金券详情
    Route::get('cashcard-detail', 'Cashcard/detail');
    //领取代金券
    Route::get('cashcard-accept', 'Cashcard/acceptCashcard');
    //选取代金券
//    Route::get('cashcard-select', 'Cashcard/select');


    //商家入驻
    Route::get('store-settle', 'Store/settle');
    //关于我们
    Route::get('about', 'Index/about');
    //店铺搜索
    Route::get('store-search', 'Store/search');
    //店铺搜索结果
    Route::get('store-result', 'Store/searchResult');
    //门店详情
    Route::get('store-detail', 'Store/detail');
    //店铺支付
    Route::get('p', 'Store/pay');

    Route::group(function () {//管理员端可访问页面
        //待发放代金券列表
        Route::get('cashcard-send', 'Cashcard/send');
        //待发放代金券详情页
        Route::get('cashcard-send-detail', 'Cashcard/sendDetail');
        //发放记录
        Route::get('cashcard-send-history', 'Cashcard/sendHistory');
    })->middleware(['admin_check']);

    Route::group(function () {//商家端可访问页面
        //收入明细
        Route::get('user-income', 'User/income');
        //收入详情
        Route::get('user-income-detail', 'User/incomeDetail');
        //我的店铺
        Route::get('store-my', 'Store/my');
    })->middleware(['merchant_check']);

    /* 页面结束 */


    /* api接口开始 */
    //获取jsSDK
    Route::post('js-sdk', 'Index/jsSDK');
    //获取用户登录信息
    Route::get('user-info', 'User/getUserinfo');
    //签到
    Route::post('sign', 'User/userSign');
    //签到记录
    Route::post('sign-record', 'User/signRecord');
    //获取附近店铺
    Route::rule('stores-nearby', 'Index/getNearbyStore', 'GET|POST');
    //获取我拥有的卡券
    Route::post('cashcard-my', 'Cashcard/myCard');
    //获取我拥有的卡券详情
    Route::post('cashcard-my-detail', 'Cashcard/cardDetail');
    //获取店铺列表（支持分类排序和搜索，按远近排序）
    Route::post('store-cate', 'Store/getCateList');
    //获取店铺列表（支持分类排序和搜索，按远近排序）
    Route::post('store', 'Store/getStoreList');
    //获取搜索记录
    Route::post('store-search-history', 'Store/searchHistory');
    //获取店铺详情（包含所有商品）
    Route::post('store-detail', 'Store/storeDetail');
    //商家入驻
    Route::post('store-settle', 'Store/settleSubmit');
    //获取卡券分类
    Route::post('cashcard-type', 'Cashcard/getCardType');
    //根据支付金额获取可用卡券
    Route::post('cashcard-check', 'Store/checkCashcard');
    //店铺支付提交
    Route::post('store-pay', 'Store/submitPay');
    //预支付跳转
    Route::any('store-prepay', 'Store/prepay');



    Route::group(function () {//管理员端可访问
        //待发放卡券
        Route::post('cashcard-send', 'Cashcard/sendList');
        //发放卡券二维码
        Route::post('cashcard-send-detail', 'Cashcard/getCardCode');
        //发放卡券历史记录
        Route::post('cashcard-send-history', 'Cashcard/getSendHistoryList');
    })->middleware(['admin_check']);

    Route::group(function () {//商家端可访问页面
        //我的店铺
        Route::post('store-my', 'Store/getMyStore');
        //收入明细
        Route::post('user-income', 'User/getFinanceFlow');
        //收入详情
        Route::post('user-income-detail', 'User/getFinanceFlowDetail');
    })->middleware(['merchant_check']);

//    Route::post();
    /* api接口结束 */

})->middleware(['token_check']);

